package at.main.gui;

import at.main.android.Graphics;
import at.main.util.AllSound;
import at.main.util.ManagerFont;

public class MenuPage {
	public static final int k_newgame = 0;

	public static final int k_contine = 1;

	public static final int k_option = 2;

	public static final int k_help = 3;

	public static final int k_about = 4;

	public static final int k_exitgame = 5;

	public int iSelectMenu = 0;

	public final String k_s0 = "Chơi tiếp";

	public final String k_s1 = "Chơi mới";

	public final String k_s2 = "Âm thanh";

	public final String k_s3 = "Hướng dẫn";

	public final String k_s4 = "Giới thiệu";

	public final String k_s5 = "Thoát";

	int iFirst = 0;

	public PlayGame playGame;

	public MenuPage() {
		iSelectMenu = 0;
		if (SoundPage.isSound) {
			AllSound.aMenuPage.playSound();
		} else {
			AllSound.aMenuPage.stopSound();
		}
	//	playGame = new PlayGame();
		// Da ton tai record store
//		if (ContinePage.ReadStore()) {
//			iFirst = 0;
//		} else {
//			iFirst = 1;
//		}
	}

	public void paint(Graphics g) {
		g.setColor(0x87CEFF);
		g.fillRect(0, 0, MyCanvas.iWidth, MyCanvas.iHeight);
		ManagerFont.drawString(g, k_s0, MyCanvas.iWidth / 2 - k_s0.length() / 2
				+ 1, MyCanvas.iHeight / 4, 2, ((0 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont.drawString(g, k_s1,
				MyCanvas.iWidth / 2 - k_s1.length() / 2,
				MyCanvas.iHeight / 4 + 20, 2, ((1 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont.drawString(g, k_s2,
				MyCanvas.iWidth / 2 - k_s2.length() / 2,
				MyCanvas.iHeight / 4 + 40, 2, ((2 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont.drawString(g, k_s3,
				MyCanvas.iWidth / 2 - k_s3.length() / 2,
				MyCanvas.iHeight / 4 + 60, 2, ((3 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont.drawString(g, k_s4,
				MyCanvas.iWidth / 2 - k_s4.length() / 2,
				MyCanvas.iHeight / 4 + 80, 2, ((4 - iSelectMenu) == 0 ? 1 : 2));
		ManagerFont
				.drawString(g, k_s5, MyCanvas.iWidth / 2 - k_s5.length() / 2,
						MyCanvas.iHeight / 4 + 100, 2,
						((5 - iSelectMenu) == 0 ? 1 : 2));
	}

	public void update() {
		if (SoundPage.isSound) {
			AllSound.aMenuPage.playSound();
		}
		// Up
		if (MyCanvas.keyHold[2]) {
			iSelectMenu--;
			if (iSelectMenu < 0)
				iSelectMenu = 5;
		}
		if (MyCanvas.keyHold[8]) {
			iSelectMenu++;
			if (iSelectMenu > 5)
				iSelectMenu = 0;
		}
		if (MyCanvas.keyHold[5]) {
			AllSound.aMenuPage.stopSound();
			switch (iSelectMenu) {
			case k_contine:
				MyCanvas.iCurrentPage = MyCanvas.k_ContineGame;				
				MyCanvas.clearInput();
				break;
			case k_newgame:
				MyCanvas.iCurrentPage = MyCanvas.k_PlayGame;
				MyCanvas.clearInput();
				break;
			case k_option:
				MyCanvas.iCurrentPage = MyCanvas.k_OptionGame;
				MyCanvas.clearInput();
				break;
			case k_help:
				MyCanvas.iCurrentPage = MyCanvas.k_HelpGame;
				MyCanvas.clearInput();
				break;
			case k_about:
				MyCanvas.iCurrentPage = MyCanvas.k_AboutGame;
				MyCanvas.clearInput();
				break;
			case k_exitgame:
				MyCanvas.iCurrentPage = MyCanvas.k_ExitGame;
				MyCanvas.clearInput();
				break;
			default:
				break;
			}
			MyCanvas.clearInput();
		}
		MyCanvas.clearInput();
	}
}
